#ifndef MAPGEN_H
#define MAPGEN_H
typedef struct {
  int x, y;
  int w, h;

  int room_type;
  int room_param;
  int creator;

  int enemy_diff;
  int activator_diff;

} roominfo;

struct mapgen_gamelevel {
	int w, h;
	unsigned char *m;
	int *r;
};

enum connection_type {
	UP = 0,
	DOWN = 1,
	LEFT = 2,
	RIGHT = 3
};

struct cplist_t {
	int x, y, r;
	enum connection_type t;
};

extern roominfo rooms[3000];
extern int total_rooms;
extern igraph_t dungeon_graph;

// Store weight informations on edges.
extern igraph_real_t *weights;
extern int weights_size;
extern int edgenbr;

// add_edge_weight put weight information in the array an resizes it
// if needed.
void add_edge_weight(int a, int b);

// Interface to the game

void (*dungeonmap_convert)(int, int, unsigned char *, int *);
void (*dungeonmap_entry_at)(roominfo *);
void (*dungeonmap_exit_at)(roominfo *);
void (*dungeonmap_place_enemies)(roominfo *);
void (*dungeonmap_gift)(roominfo *);

int generate_dungeon(int, int, int, int);

int generate_dungeon_meritous(int, int);
int generate_dungeon_gram(int, int);

void destroy_dungeon(void);

void mapgen_put_tile(int x, int y, unsigned char tile, int room);
unsigned char mapgen_get_tile(int x, int y);
int mapgen_get_room(int x, int y);
void mapgen_draw_room(int place_x, int place_y, int room_w, int room_h, int room_id);

int find_connection_points(int room_id, struct cplist_t cplist[300]);

void MakeConnect(int x, int y, enum connection_type type);

#endif

